package cst.a526whx.sanjixiangmu_526whx;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * Created by ZHANG on 2017/5/22.
 */

public class RegActivity extends AppCompatActivity {
    private EditText username;
    private EditText password;
    private Button button3;
    private Button button2;
    private Button reg_stu;
    private Button reg_tea;
    private EditText realname;
    private EditText tel;
    private EditText roleid;
    private EditText email;
    private ResModel model;
    private AmicoolListener<LoginBean> listener;
    private  String rr=null;
    @Override

    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        username=(EditText)findViewById(R.id.reg_username);
        password=(EditText)findViewById(R.id.reg_password);
        realname=(EditText)findViewById(R.id.reg_realname);
        tel=(EditText)findViewById(R.id.reg_tel);
        email=(EditText)findViewById(R.id.reg_email);
        button2=(Button)findViewById(R.id.reg_tijiao);
        button3=(Button)findViewById(R.id.reg_quxiao);
        reg_stu=(Button)findViewById(R.id.reg_stu);
        reg_tea=(Button)findViewById(R.id.reg_tea);
        listener=new AmicoolListener<LoginBean>() {
            @Override
            public void onResponse(LoginBean l) {
                if(l.equals("1")){//?
                    Toast.makeText(RegActivity.this, "恭喜您，注册成功", Toast.LENGTH_SHORT).show();


                }
                else{
                    Toast.makeText(RegActivity.this,"注册失败",Toast.LENGTH_SHORT).show();

                }



            }

            @Override
            public void onReponse(LoginBean l) {

            }

            @Override
            public void onFail(String msg) {
                Toast.makeText(RegActivity.this,msg,Toast.LENGTH_SHORT).show();

            }
        };
        reg_stu.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                rr="2";
            }
        });
        reg_tea.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                rr="3";
            }
        });



        button2.setOnClickListener(new View.OnClickListener(){//按了提交之后

            @Override
            public void onClick(View view) {
                model= new ResModel("gson") {
                    @Override
                    public void reg(String s, String s1, String s2, String rr, String s3, String s4, AmicoolListener listener) {

                    }

                    @Override
                    public void Login(String u, String p, AmicoolListener l) {

                    }

                    @Override
                    public void reg(String u, String p, String t, int roleid, String email) {

                    }

                    @Override
                    public void getList(String mod, int page, String s, AmicoolListener l) {

                    }

                    @Override
                    public void getVideotDetail(String mod, int id, String s, AmicoolListener l) {

                    }
                };
                model.reg(username.getText().toString(),password.getText().toString(),tel.getText().toString(),rr,
                        realname.getText().toString(),email.getText().toString(),listener);


            }


        });

        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(RegActivity.this,LoginActivity.class);
                startActivity(intent);
            }
        });//返回上一个intent







    }







}
